var shareAfterFavOrDownload = 0; // 1 为收藏后转帖   2 为下载后转帖
function setSharePoint(point){         // 1 为收藏后转帖   2 为下载后转帖
	shareAfterFavOrDownload = point;
}
//隐藏消息提示框
function hiddenTextareaImp(){
	var o = document.getElementById("textarea_imp");
	o.style.display="none";
}
function showTextareaImp(){
	var o = document.getElementById("textarea_imp");
	o.style.display="";
}
//财经微博转帖
function hexun(){
	(function(s,d,e,t,z){
	var f='http://t.hexun.com/channel/shareweb.aspx?',u=z||d.location,p=['title=',e(t||d.title),'&url=',e(u)].join('');
	function a(){if(!window.open([f,p].join(''),'wb',['toolbar=0,status=0,resizable=1,width=636,height=326,left=',(s.width-636)/2,',top=',
	(s.height-326)/2].join('')))u.href=[f,p].join('');};
	if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else a();})
	(screen,document,encodeURIComponent,'','')
}
//弹出分享
function openShare(pid){

	var url = "/app/my/docin/fansCount?rank=" + new Date().getTime();
	jQuery.post(url,null,function(data){
		if(data == 0){
			document.getElementById("divcss").style.display = "none";
			document.getElementById("divcss2").style.display = "none";
		}
		shareEvent(pid,13);
		document.getElementById("cbSelectSuccess").style.display = "block";
		document.getElementById("docinPopBox1").style.display = "block";
	});
	
	
}
function copyUrl(desId){
	var obj=document.getElementById(desId);
	inputFus(desId)
	if(window.ActiveXObject){
		ClipCopy = obj.createTextRange();
        ClipCopy.execCommand("Copy");
	}else{
		document.getElementById("textUrlError").style.display = "none";
		document.getElementById("flUrlError").style.display = "none";
		document.getElementById("endShareCodeError").style.display = "none";
		document.getElementById(desId + "Error").style.display = "block";
		return;
	}	

}

function changeSize(url,w,h,obj){
var str = '<embed src="'+url+'" width="'+w+'" height="'+h+'" type="application/x-shockwave-flash" ALLOWFULLSCREEN="true" ALLOWSCRIPTACCESS="always"></embed>';
	document.getElementById("endShareCode").value=str;
	var oBox=document.getElementById('b_size');
	var aLI=oBox.getElementsByTagName('a');
	var i=0;			
	for(i=0;i<aLI.length;i++)
	{
		aLI[i].index=i;
			for(i=0;i<aLI.length;i++)
			{
				aLI[i].className="";
			}
	}
	obj.className="cur";
} 
function shareStart(pid){
	var li = jQuery("#friend-lists li");
	var idArr=[];
	for(var i=1;i<li.length;i++){
		idArr.push(jQuery(li[i]).attr('id').replace("af_",""));
	}
	if(idArr == null || idArr.length == 0){
		document.getElementById("endShare_Tip").style.display='block';
		return;
	}
	var url= "/app/share/shareEmail?user_id=" + idArr.join(',') + "&productId=" + pid;
	jQuery("#a5").load(url);
	alert("分享成功！");
	document.getElementById('docinPopBox1').style.display='none';
}
function inputFus(desId){
	document.getElementById(desId).focus();
	document.getElementById(desId).select();
}
//留言
function insertUserMessage(notLogin) {

	
	var d = document,
		messageText = d.getElementById("message"),
		message = trim(messageText.value),
		productId = d.getElementById("productId").value,
		userIp = d.getElementById("userIp").value,
		insertMB = d.getElementById("insertMessageBtn");
	if(message == ""){
		alert("留言文字不能为空！");
		messageText.select();
		return ;
	}
	if(message.length > 1000){
		alert("留言文字太长，不能超过1000个字！");
		messageText.select();
		return ;
	}
	var code ='';
	if(notLogin == 1){//检查验证码
		code = d.getElementById("checkout").value;
		if(code == ''){
			alert("验证码为空");	
			return ;
		}else if(code.length!=4){
			alert("验证码长度应为4");	
			return ;
		}
	}
	insertMB.disabled = true;
	jQuery("#a5").load("/jsp_cn/jquery/end/product_message.jsp?pid="+productId+"&islogin="+notLogin+"&code="+code+"&userIp="+userIp+"&message="+encodeURI(message)+"&date="+new Date().getTime());
	
}
function recommendProduct_zhf(notLogin){
	/*if(notLogin == 1){
		alert("提示：请先登录，然后再推荐！");
		return;
	}*/
	var d = document,
		messageText = d.getElementById("recommendMessage"),
		message = jQuery.trim(messageText.value),
		productId = d.getElementById("productId").value,
		insertMB = d.getElementById("insertRecommendMessageBtn");
	if(message == ""){
		alert("推荐理由文字不能为空！");
		messageText.select();
		return ;
	}
	if(message.length > 1000){
		alert("推荐理由文字太长，不能超过1000个字！");
		messageText.select();
		return ;
	}
	insertMB.disabled = true;
	jQuery("#jquerydiv").load("/app/jquery/mingrenrecom?pid="+productId + "&recommendMessage=" + encodeURI(message)+"&d=" + new Date().getTime());
	insertMB.disabled = false;
}

//不刷新页面加载消息
function ajaxAddUserMsg(){
	var d=document,
  userMessageDiv = d.createElement("ajaxMessageTemplet");
	msg = d.getElementById("ajaxMessageTemplet").innerHTML;
	msg1 = d.getElementById("message").value;
	msg1 = msg1.replace(/</ig,"&lt;");
	msg1 = msg1.replace(/\r\n/ig,"<br/>");
	msg = msg.replace("userMessage",msg1);
	var messageCount = Math.floor(d.getElementById("messageCount").value)+1;
	d.getElementById("messageCount").value = messageCount;
	msg = msg.replace("messageCount",messageCount);
	//msg = msg.replace("messageCount","");
	userMessageDiv.innerHTML = msg;
	var addMsgDiv = d.getElementById("ajaxAddUserMessage");
	var showMsgDiv = d.getElementById("ajaxAddUserMessageBottom");
	showMsgDiv.innerHTML = addMsgDiv.innerHTML+showMsgDiv.innerHTML;
	addMsgDiv.innerHTML = "";
	addMsgDiv.innerHTML = msg;
	var total = d.getElementById("total").value;
	if(total == 0){
		var con = d.getElementById("showMsgContent").innerHTML;
		con = con.replace("暂无评论。","");
		d.getElementById("showMsgContent").innerHTML = con;
	}
	var t = parseInt(total) + parseInt(1);
	d.getElementById("total").value = t;
}
function setStepon(productId,auditLevel){
	
	if(auditLevel!=1) return;
	
	var productIdValue = getCookie2008_1(productId);
	var cookieIdValue = getCookie2008_1("cookie_id");
	if(cookieIdValue==null){
		alert("你的浏览器不支持cookie功能,请确认!");
		return;
	}
	var url = "/jsp_cn/jquery/end/update_message.jsp?pid="+productId+"&flag=stepon&date="+new Date().getTime();
	if(productIdValue==null){	//没有顶过
		setCookie2008_1(productId,cookieIdValue,60*24*365);
		jQuery("#a5").load(url);
	}else{
		if(productIdValue != cookieIdValue){	//该用户没有顶过
			setCookie2008_1(productId,cookieIdValue,60*24*365);
			jQuery("#a5").load(url);
		}else{
			alert("你已经投过票了，请不要重复投票");
		}
	}

}
function setTop(productId,auditLevel){
	/**
	 * 1 取出cookie_id的值
	 * 2 判断key = productId的这个cookie是否存在
	 * 3 比较两个值是否相等
	 */
	if(auditLevel!=1) return;
	var productIdValue = getCookie2008_1(productId);
	var cookieIdValue = getCookie2008_1("cookie_id");
	if(cookieIdValue==null){
		alert("你的浏览器不支持cookie功能,请确认!");
		return;
	}
	var url = "/jsp_cn/jquery/end/update_message.jsp?pid="+productId+"&flag=top&date="+new Date().getTime();
	if(productIdValue==null){	//没有顶过
		setCookie2008_1(productId,cookieIdValue,60*24*365);
		jQuery("#a5").load(url);
	}else{
		if(productIdValue != cookieIdValue){	//该用户没有顶过
			setCookie2008_1(productId,cookieIdValue,60*24*365);
			jQuery("#a5").load(url);
		}else{
			alert("你已经投过票了，请不要重复投票");
		}
	}
	shareEvent(productId,14);
}

//删除消息
function deleteMessage(messageId){	
	var d=document,productId=d.getElementById("productId").value;

	if(confirm("确定要删除吗？")){
		var url = "/jsp_cn/jquery/end/update_message.jsp?pid="+productId+"&mId="+messageId+"&flag=del_mess&date="+new Date().getTime();
		jQuery("#a5").load(url);
	}
}

//隐藏消息标签
function hiddenMessage(messageId){
	 var d=document,o= d.getElementById("userMessageDIV"+messageId);
	 o.style.display="none";
}

//显示回复消息输入框
function showOrHiddenReMessageText(reMsgDivId){	
	var d=document,t=d.getElementById(reMsgDivId);
	t.style.display=(t.style.display=="")?"none":"";
	if(t.style.display==""){
		v='regimg_re'+reMsgDivId.replace("reMsgDiv","");
		refCode(v);
	}
}

//重置验证码
function refCode(img_id){
	var d=document,checkImg=d.getElementById(img_id);
	//alert(checkImg);
	if(checkImg!=null){
		checkImg.src="/servlet/getimg?"+getTime();
	}
}

function getTime(){
	var d, s = "";
	var c = "";
	d = new Date();
	s += d.getYear()+c;
	s += (d.getMonth() + 1) + c;
	s += d.getDate() + c;
	s += d.getHours() + c;
	s += d.getMinutes() + c;
	s += d.getSeconds() + c;
	s += d.getMilliseconds();
	return s;
}

//插入回复信息
function insertReMessage(reMessageTextId,messageId,senderId,notLogin){
	var d=document,
  reMessageText=d.getElementById(reMessageTextId),
  reMessage = reMessageText.value,
  productId=d.getElementById("productId").value,
  userIp = d.getElementById("userIp").value;
	reMessage=trim(reMessage);
	if(reMessage==""){
		alert("留言文字不能为空！");
		reMessageText.select();
		return ;
	}
	if(reMessage.length>1000){
		alert("留言文字太长，不能超过1000个字！");
		reMessageText.select();
		return ;
	}
	var code ='';
	if(notLogin==1){//检查验证码
		code = d.getElementById("checkout_re"+messageId).value;
		if(code==''){
			alert("验证码为空");	
			return ;
		}else if(code.length!=4){
			alert("验证码长度应为4");	
			return ;
		}
	}
	
/*	reMessage=reMessage.replace(/\r\n/ig,"<br/>");	
	var url = "/jsp_cn/jquery/end/update_message.jsp?reMessage="+encodeURI(reMessage)+"&pid="+productId+"&messageId="+messageId+
				"&senderId="+senderId+"&notLogin="+notLogin+"&code="+code+"&flag=insertReMes&date="+new Date().getTime();
	jQuery("#a5").load(url);
*/	
	jQuery("#a5").load("/jsp_cn/jquery/end/product_message.jsp?pid="+productId+"&islogin="+notLogin+"&code="+code+"&userIp="+userIp+"&message="+encodeURI(reMessage)+"&returnid="+messageId+"&date="+new Date().getTime());
}

//显示验证码
function showCheckCode(){
	var cv=$("checkCodeDiv");
	if(cv!=null&&cv.style.display!=""){
			cv.style.display="";
			refCode('regimg');
	}
}

//回复消息内容
function setMsgContent(productId){
	var d=document,msg_c_name="msg_content_cookie_"+productId;
	temp=getCookie2008_1(msg_c_name);
	if(temp!=null && temp!="null"){
		d.getElementById("message").value=temp;
	}
}

//显示回复div
function showReMessageDiv(reUserProductMessageId,reMessage){
    var d=document,
     reMsgDiv=	d.getElementById("reMessageContent"+reUserProductMessageId);
     reMsg=reMsgDiv.innerHTML;
     reMsg=reMsg.replace("reMessageCount",reMessage);
     reMsgDiv.innerHTML=reMsg;
     reMsgDiv.style.display="";
}

//设置回复连接href
function setReMsgDelA_href(reMessageId,messageId){
	var d=document,
  a=d.getElementById("reMsgDelA"+messageId);
	if(a!=null){
			a.href="javascript:deleteReMessageAjax("+reMessageId+","+messageId+")";		
	}
}

//删除回复信息
function deleteReMessageAjax(reUserProductMessageId,userProductMessageId){
	var d=document,
  productId=d.getElementById("productId").value;
//reMessageContent
	if(confirm("确定要删除吗？")){
		var url = "/jsp_cn/jquery/end/update_message.jsp?reUserProductMessageId="+reUserProductMessageId+
			"&pid="+productId+"&userProductMessageId="+userProductMessageId+"&flag=deleteReMessage&date="+new Date().getTime();
		jQuery("#a5").load(url);
	}
}

//显示回复连接
function hiddenReMsgA(userProductMessageId){	   
		var d=document;
  d.getElementById("reMsgA"+userProductMessageId).style.display="none";
}

//删除回复信息
function deleteReMessage(reUserProductMessageId,userProductMessageId){
	var d=document,
  productId=d.getElementById("productId").value;
//reMessageContent
	if(confirm("确定要删除吗？")){
		var url = "/jsp_cn/jquery/end/update_message.jsp?reUserProductMessageId="+reUserProductMessageId+
			"&pid="+productId+"&userProductMessageId="+userProductMessageId+"&flag=deleteReMessage&date="+new Date().getTime();
		jQuery("#a5").load(url);
	}
}

//隐藏回复div
function hiddenReMessageDiv(reUserProductMessageId){
	 var d=document,
   reMsgDiv=	d.getElementById("reMessageContent"+reUserProductMessageId);
  reMsgDiv.style.display="none";
}

//显示回复连接
function showReMsgA(userProductMessageId){	   
		var d=document;
  d.getElementById("reMsgA"+userProductMessageId).style.display="";
}

//分类
function setCategory(id){
	var d=document,
  categoryId = d.getElementById("categoryBeanId").value;
	if(categoryId!="0"){
		var url = "/jsp_cn/jquery/end/update_message.jsp?categoryId="+categoryId+
					"&pid="+id+"&flag=setCategory&date="+new Date().getTime();
		jQuery("#a5").load(url);
	}else{
		alert("请选择分类!");
	}
}

//文档详细信息显示
function showDesc(){
	$("descTemp").style.display="none";
	$("descAll").style.display="block";
}
function showTemp(){
	$("descTemp").style.display="block";
	$("descAll").style.display="none";	
}
//举报
function   getXYWH(o){
var   nLt=0;
var   nTp=0;
  var   offsetParent   =   o;
  while   (offsetParent!=null   &&   offsetParent!=document.body)   {
  nLt+=offsetParent.offsetLeft;
  nTp+=offsetParent.offsetTop;
  offsetParent=offsetParent.offsetParent;
  }
  this.showL=nLt;
  this.showT=nTp;
  this.showW=o.offsetWidth;
  this.showH=o.offsetHeight;
}
function showFeekback(obj,elem){
 var d=document,
 o=d.getElementById(obj),
 s=d.getElementById(elem);
 if(!o||!s) return false;
  s.onclick=function(){
  var sObj=new getXYWH(this);
  _left=(sObj.showL>800)?("right:68px;"):("left:"+(sObj.showL)+"px;");
  o.style.cssText = ";top:"+(sObj.showT+25)+"px;"+_left;
  if(elem == "recommendMessageButtun"){
	  var productId = d.getElementById("productId").value;
  	  var sendUrl = "/app/jquery/isRecommendProduct?pid="+productId + "&rand="+new Date().getTime();
	  var result = trim(jQuery.ajax({url: sendUrl, async: false}).responseText); 
	  if(result == "true"){
	  	  removeClass(o,"display-n");
		  d.getElementById("recommendedMessageDiv").style.display = "block";
		  d.getElementById("reportMessageDiv").style.display = "none";
	  }else{
	  	  d.getElementById("recommendedMessageDiv").style.display = "none";
		  d.getElementById("reportMessageDiv").style.display = "none";
	  	  jQuery("#jquerydiv").load("/app/jquery/mingrenrecom?pid="+productId +"&date="+new Date().getTime()); 
	  }
	  //alert(" 1 "+elem);
	 // alert("recommendedMessageDiv : " + d.getElementById("recommendedMessageDiv").style.display);
	 // alert("reportMessageDiv : " + d.getElementById("reportMessageDiv").style.display);
  }else{
  		removeClass(o,"display-n");
  	  d.getElementById("recommendedMessageDiv").style.display = "none";
	  d.getElementById("reportMessageDiv").style.display = "block";
	 // alert(" 2 "+elem);
	 // alert("recommendedMessageDiv : " + d.getElementById("recommendedMessageDiv").style.display);
	 // alert("reportMessageDiv : " + d.getElementById("reportMessageDiv").style.display);
  }
  }
}
function hiddenFeekback(){
var d=document;
d.getElementById("subTip").innerHTML="输入与之重复的另一篇文档URL地址";
d.getElementById("subTip").style.color = "#000";
d.getElementById("purl").value="";
var o=document.getElementById("feekBackDiv");
addClass(o,"display-n");
}
//发送举报消息
function sendFeekBack(id){
	var d=document,
  content = "",
  type = 2 ,errs="";
 	var error3 = d.getElementById("error3").value;
	if(error3==""){	//没有填写举报内容testarea
		if(d.getElementById("error1").checked){
			type = type + 3;
			content = d.getElementById("error1").value;
		}else if(d.getElementById("error2").checked){
			type = type + 5;
//			content = d.getElementById("error2").value;
			content = d.getElementById("purl").value; 
			if(content==""||content.length<1||content=="输入与之重复的另一篇文档URL地址"){
				alert("请输入重复文档!");
				return ;
			}else{
				var begin=content.indexOf("-");
				var  end=content.lastIndexOf(".html");
				if(begin==-1 || end==-1){
					alert("输入正确网址");
					return;
				}else{
				var jbid=content.substring(begin+1,end);

				if(parseInt(jbid)>parseInt(id)){
				  alert("您的举报无效，请核实举报文档的上传时间");
				  return;
				}else if(parseInt(jbid)==parseInt(id)){
				 d.getElementById("subTip").innerHTML="输入文档链接有误，不能举报同一篇文档！";
				 d.getElementById("subTip").style.color = "#f00";
				 return;
				 }
			  }
			}
			
		}else if(d.getElementById("error4").checked){
			type = type + 4;
			content = d.getElementById("error4").value;
		}else if(d.getElementById("error5").checked){
			type=type+2;
			content = d.getElementById("error5").value;
			var mes=document.getElementsByName("errors");
			for(var i=0;i<mes.length;i++){
				if(mes[i].checked){
				content=content+mes[i]+" ";
				}
			}
		}else{
			alert("请添写或选择举报信息!");
			return;
		}
	}else{
		content = error3;
		if(d.getElementById("error2").checked){
			type = type + 5;
//			content = d.getElementById("error2").value;
			content = d.getElementById("purl").value; 
			if(content==""||content.length<1||content=="输入与之重复的另一篇文档URL地址"){
				alert("请输入重复文档!");
				return ;
			}else{
				var begin=content.indexOf("-");
				var  end=content.lastIndexOf(".html");
				if(begin==-1 || end==-1){
					alert("输入正确网址");
					return;
				}else{
				var jbid=content.substring(begin+1,end);

				if(parseInt(jbid)>parseInt(id)){
				alert("您的举报无效，请核实举报文档的上传时间");
				return;
				}else if(parseInt(jbid)==parseInt(id)){
				 d.getElementById("subTip").innerHTML="输入文档链接有误，不能举报同一篇文档！";
				 d.getElementById("subTip").style.color = "#f00";
				 return;
				 } 
			  }
			}
			
		}
	}
	var url = "/jsp_cn/jquery/end/update_message.jsp?content="+encodeURI(content)+
					"&pid="+id+"&type="+type+"&flag=sendFeekBack&date="+new Date().getTime();
		jQuery("#a5").load(url);
}

//回复消息内容
function setMsgContent(productId){
	var d=document,
  msg_c_name="msg_content_cookie_"+productId;
	temp=getCookie2008_1(msg_c_name);
	if(temp!=null && temp!="null"){
		d.getElementById("message").value=temp;
	}
}

function favorite(title){
	if ((typeof window.sidebar == 'object') && (typeof window.sidebar.addPanel == 'function'))//Gecko
	{
		window.sidebar.addPanel(title,location.href,'');
	}else if (window.MessageEvent && !document.getBoxObjectFor){
		alert("请使用ctrl+d快捷键收藏本页！");
	 	
	}else{
		window.external.AddFavorite(location.href,title);
	}

 		
 	}
 	
 function wenbao(){
 	/*
 	if(userid_app!=null){
 		window.open('http://v.t.sina.com.cn/share/share.php?appkey=750339144&title='+encodeURIComponent(document.title)+'&url='+encodeURIComponent(location.href+'&uid='+userid_app)+'&source=bookmark&ralateUid=1644855885','_blank','width=450,height=400');
 	}else{
 		window.open('http://v.t.sina.com.cn/share/share.php?appkey=750339144&title='+encodeURIComponent(document.title)+'&url='+encodeURIComponent(location.href)+'&source=bookmark&ralateUid=1644855885','_blank','width=450,height=400');
 	}
 	*/
 	jQuery("#a5").load("/app/wbzt/join");
 	jQuery.post("/jsp_cn/renrenShareCallback.jsp?rand="+new Date().getTime());
 	if(shareAfterFavOrDownload==1){
		setConnectQueue(0,13,js_pid);
	}
	if(shareAfterFavOrDownload==2){
		setConnectQueue(0,17,js_pid);
	}
	shareAfterFavOrDownload=0;
 	bShare.share(null,'sinaminiblog',0);
 	
 }	
 function sohubai(){
    jQuery.post("/jsp_cn/renrenShareCallback.jsp?rand="+new Date().getTime());
 	if(window.MessageEvent && !document.getBoxObjectFor){
 		alert("白社会快速转帖暂不能支持Chrome等个别浏览器，请复制本文链接前往白社会手动转帖。");
 		return false;
 	}
 	var url = 'http://bai.sohu.com/share/blank/addbutton.do?from=docin&amp;link='+location.href+'&amp;title='+document.title;
 	window.open(url);
 	
 }


function kaixin(){
	/*
	var url = "http://www.kaixin001.com/~repaste/repaste.php";
	url += "?rtitle="+stitle;
	url += "&rurl="+encodeURIComponent(location.href);
	url += "&rcontent="+scontent;
	window.open(url);
	*/
	jQuery.post("/jsp_cn/renrenShareCallback.jsp?rand="+new Date().getTime());
	bShare.share(null,'kaixin001',0);
}

function douban(){
	/*
	var url = "http://www.douban.com/recommend/";
	url += "?url="+encodeURIComponent(location.href);
	url += "&title="+stitle;
	window.open(url);
	*/
	jQuery.post("/jsp_cn/renrenShareCallback.jsp?rand="+new Date().getTime());
	bShare.share(null,'douban',0);
}

function qq(){
	/*
	var url = "http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey";
	var location_app=location.href;
	if(userid_app!=null && userid_app!=''){
		location_app=location.href+"&uid="+userid_app;
	}
	
	url = url + "?url=" + encodeURIComponent(location_app);
	//alert(url);
	window.open(url);
	*/
	jQuery("#a5").load("/app/qqzt/join");
	jQuery.post("/jsp_cn/renrenShareCallback.jsp?rand="+new Date().getTime());
	if(shareAfterFavOrDownload==1){
		setConnectQueue(0,12,js_pid);
	}
	if(shareAfterFavOrDownload==2){
		setConnectQueue(0,16,js_pid);//userType,operate,productId
	}
	shareAfterFavOrDownload=0;
	bShare.share(null,'qzone',0);
}
function postToWb(){//腾讯微博
	jQuery.post("/jsp_cn/renrenShareCallback.jsp?rand="+new Date().getTime());
	if(shareAfterFavOrDownload==1){
		setConnectQueue(0,21,js_pid);
	}
	if(shareAfterFavOrDownload==2){
		setConnectQueue(0,22,js_pid);
	}
	shareAfterFavOrDownload=0;							
	bShare.share(null,'qqmb',0);
}
function baidu(){
	window.open('http://cang.baidu.com/do/add?it='+encodeURIComponent(document.title.substring(0,76))+'&iu='+encodeURIComponent(location.href)+'&fr=ien#nw=1','_blank','scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes'); 
}

function youshi(){
	//var url = 'http://www.Ushi.cn/feedShare/feedShare!sharetomicroblog.jhtml?type=button&loginflag=share&title='+stitle+'&url='+encodeURIComponent(location.href);
	//window.open(url,'_blank','width=600,height=550,resizable=yes');
	bShare.share(null,'ushi',0);
}


function share2MSN(){
	//var url = "http://profile.live.com/badge?url=" + msnShareUrl;
	//window.open(url);
	jQuery.post("/jsp_cn/renrenShareCallback.jsp?rand="+new Date().getTime());
	bShare.share(null,'msn',0);
}
//播放器调用终极页转帖
function weiboBtnZhuanTie(){wenbao();}
function tengxunBtnZhuanTie(){postToWb();}
function kaixinBtnZhuanTie(){kaixin();}
function feixinBtnZhuanTie(){
	/*
	var f=window.document.title;
	var d=document.getElementById('share_fx')
	var e='http://space.feixin.10086.cn/api/share?source=sharelink&title='+escape(f)+'&url='+escape(window.location.href);
	window.open(e);
	*/
	jQuery.post("/jsp_cn/renrenShareCallback.jsp?rand="+new Date().getTime());
	bShare.share(null,'feixin',0);
}
function msnBtnZhuanTie(){share2MSN();}
function youBtnZhuanTie(){youshi();}

//显示背景
function showBg(){
	var d=document,sWidth,sHeight;
		sWidth=d.body.offsetWidth;
		sHeight=d.body.offsetHeight;//screen.height;
		var bgObj=d.createElement("div");
		bgObj.setAttribute('id','bgDiv');
		bgObj.setAttribute('name','bgDiv');
		bgObj.style.cssText = ";position:absolute;top:0;left:0;z-index:10000;width:"+sWidth+"px;height:"+sHeight+"px;"+"background:#777;filter:Alpha(opacity=60);opacity:0.6;";
		d.body.appendChild(bgObj); 
}
//移除背景
function removeBg(){
	var bgObj=$("bgDiv");	
	document.body.removeChild(bgObj);	
}

function closeGroup(){
	$("groupIframe").src="";
	$("groupIframe").style.display="none";
	$("groupIframe").style.zIndex = "10000";
	removeBg();
}

var favorat_e=true;
function favorate_p(pid){
	if(favorat_e==true){
		favorat_e=false;
		var url = "/jsp_cn/jquery/end/update_message.jsp?"+
					"pid="+pid+"&flag=favorate_p&date="+new Date().getTime();
		jQuery("#a5").load(url);
	}
}
function favorate_p_back(data){
	//alert(data);
	//-1：未登录 -2:商品id为空   0:失败 1:成功 3:已收藏
	switch(data){
		case -1:login();break;
		case -2:alert("文档不存在！");break;
		case 0:alert("收藏失败，请重试");break;
		case 3:alert("你已经收藏过此文档");break;
		case 4:alert("你已经收藏200个文档，不能再收藏");break;
		case 1:
				$("favorate_count").innerHTML=1+parseInt($("favorate_count").innerHTML);
				$("favorate_count_top").innerHTML=1+parseInt($("favorate_count_top").innerHTML);
				alert("收藏成功!");	
				break;
	}
	favorat_e=true;
}

function showMessageContent(){
	var d=document,
  cpage = d.getElementById("msgcpage").value,
  pid = d.getElementById("productId").value,
  isMy = d.getElementById("ismy").value;
	if(isMy == "") isMy = "0";
	var total = d.getElementById("total").value,
  userIp = d.getElementById("userIp").value,
  url = "/jsp_cn/jquery/end/message.jsp?page="+cpage+"&pid="+pid+"&ism="+isMy+"&to="+total+"&userIp="+userIp+"&date="+new Date().getTime();;
	jQuery("#showMsgContent").load(url);
}
function showMessageU(currentPage){
	var d=document,
  cpage = currentPage,
  pid = d.getElementById("productId").value,
  isMy = d.getElementById("ismy").value;
	if(isMy == "") isMy = "0";
	var total = d.getElementById("total").value,
  url = "/jsp_cn/jquery/end/message.jsp?page="+cpage+"&pid="+pid+"&ism="+isMy+"&to="+total+"&date="+new Date().getTime();
	jQuery("#showMsgContent").load(url);
}

function rr_login_flash(){
	var url = '/jsp_cn/renren/call.jsp?page=end' + js_pid;
	window.open(url,'new','height='+450+',innerHeight='+450+',width='+500+',innerWidth='+500+',top='+200+',left='+200+',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');	
}

function sina_login_flash(){
	var url = '/jsp_cn/weibo/call.jsp?page=end' + js_pid;
	window.open(url,'new','height='+450+',innerHeight='+450+',width='+500+',innerWidth='+500+',top='+200+',left='+200+',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
}
function qq_login_flash(){
	var url = '/jsp_cn/qq/call.jsp?page=end' + js_pid;
	window.open(url,'new','height='+400+',innerHeight='+400+',width='+450+',innerWidth='+450+',top='+200+',left='+200+',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
}
function setCookie(cookiename,cookievalue)
{
    document.cookie = cookiename + "=" + cookievalue + "; path=/";
}

function shengda_login_flash(){
	setCookie("shengda_end",js_pid);
	
	showsd();
}

function renren(){
	jQuery("#a5").load("/app/rrzt/join");
	jQuery.post("/jsp_cn/renrenShareCallback.jsp?rand="+new Date().getTime());
	XN.Connect.showShareDialog(shareInfo, function(confirm) {
		if(confirm){
			if(shareAfterFavOrDownload==1){
				setConnectQueue(0,11,js_pid);
			}
			if(shareAfterFavOrDownload==2){
				setConnectQueue(0,15,js_pid);
			}
			shareAfterFavOrDownload=0;
			bShare.stats(null,'renren',0);
		}
    });	
}

//---------------0730 终极页播放器缩进------------------//
/* function hideEndList(){
	var 	o = $("DocinViewer"),
		s = $("sider"),
		i = $("indent-flash");
	s.style.display="none";
	addClass(o,"doc-player-tips");
	i.style.display="block";
 }
 function showEndList(){
	var o = $("DocinViewer"),
		s = $("sider"),
		i = $("indent-flash");
	s.style.display="block";
	removeClass(o,"doc-player-tips");
	i.style.display="none";
 }*/
  function hideEndFlash(){
	var 	o = $("DocinViewer"),
		s = $("sider"),
		i = $("small-flash"),
  j = $("big-flash"),
  m = $("downdiv"),
  d =$("doudanSlider");
  if(!o||!s||!i||!j||!m) return false;
 addClass(s,"display-n");
	addClass(o,"doc-player-tips");
 removeClass(i,"display-n");
 addClass(j,"display-n");
 addClass(m,"display-n");
 addClass(d,"display-n");
 }
 function showEndFlash(){
	var o = $("DocinViewer"),
		s = $("sider"),
		i = $("small-flash"),
  j = $("big-flash"),
  m = $("downdiv"),
  d =$("doudanSlider");
  if(!o||!s||!i||!j ||!m) return false;
	removeClass(s,"display-n");
	removeClass(o,"doc-player-tips");
	addClass(i,"display-n");
 removeClass(j,"display-n");
 removeClass(m,"display-n");
 removeClass(d,"display-n");
 }
 function getCookieId(){
	 var cc = new CookieClass();
	 var cookieId = cc.getCookie("cookie_id");
	 return cookieId;
 }
 function changeRadio_v83(){
 	var d = document;
 	var obj = d.getElementById("error2");
 	var obj5 = d.getElementById("error5");
  d.getElementById('repeatproduct').style.display=(obj.checked)?"block":"none";
  d.getElementById('zlresult').style.display=(obj5.checked)?"block":"none";
 }
 function changeRadio(){
 	var d = document;
 	var obj = d.getElementById("error2");
  d.getElementById("subTip").innerHTML="输入与之重复的另一篇文档URL地址";
  d.getElementById("subTip").style.color = "#000";
  d.getElementById("purl").value="";
  d.getElementById('repeatproduct').style.display=(obj.checked)?"block":"none";
 }

 /*pageFullScreen 2010-12-17 kouyubo*/
function pageFullScreen(v){
var v,i,j,o,e,d=document,
 arr = ["docinAd","end-cramNav","ifs","endheader","downdiv","head_wapper","end","shop-end","sider","small-flash","big-flash","luceneDiv","info-end","commonts-end","foot","bannerForend","feekBackDiv","doudanSlider"],
 arrs = ["html","body","wapper-end","player-end","DocinViewer"],
 ifs = d.getElementsByTagName("iframe"),
 rrIframe = ifs[(ifs.length-2)];
for(i=0;i<arr.length;i++){
 o = d.getElementById(arr[i]);
 if(!!!o){continue;}
 if(!!!v){
 addClass(o,"d-n");
 addClass(rrIframe,"d-n");
 }else{
 removeClass(o,"d-n");
 removeClass(rrIframe,"d-n");
 }
}
for(j=0;j<arrs.length;j++){
 e = d.getElementById(arrs[j]) || d.getElementsByTagName(arrs[j])[0];
 if(!!!v){
 addClass(e,"maxHeight");
 }else{
 removeClass(e,"maxHeight");
 }
}
return 1;
}
 
function send_weibo(pname,pid){
	jQuery("#setwb").load("/jsp_cn/weibo/action_update.jsp?pid="+pid+"&proname="+encodeURI(pname)+"&type=1");
}
/*循环滚动代码*/
function marqueeAuto(outEle,wrap1,wrap2,speed){
/**
*outEle 外层元素id
*wrap1包裹元素1 id
*wrap2包裹元素2 id
*speed滚动速度
**/
	var d = document;
	var wrap = d.getElementById(outEle);
	var wrap1 = d.getElementById(wrap1);
	var wrap2 = d.getElementById(wrap2);	
	speed= ""?100:speed;
	wrap2.innerHTML = wrap1.innerHTML;
	function Marquee(){
	    if(wrap2.offsetTop-wrap.scrollTop<=0)    
	        wrap.scrollTop-=wrap1.offsetHeight ;  
	    else{
	        wrap.scrollTop++;
	    }
	}	
	var MyMar = setInterval(Marquee,speed);
	wrap.onmouseover = function(){clearInterval(MyMar)};
	wrap.onmouseout = function(){MyMar = setInterval(Marquee,speed)};	
}
//终极页加入豆单按钮
function insertDoclist(){
	//发送ajax请求  判断用户是否创建过豆单
	var url = "/my/docin/doclist/insertdoclist.do?random="+Math.round(Math.random()*100);
	jQuery.post(url,null,function(data){
		if(data != null){
			var json = eval('(' + data + ')');
			var result = json.result;
			if(result == 0){
				//未登录 弹出登陆框
				showlogin();
			}else if(result == 1){
				//已登录 没有豆单
				document.getElementById('createDoudan').style.display="";
			}else if(result == 2){
				//已登录 有豆单
				var doclist = json.doclist;
				if(doclist != null){
					document.getElementById('doclistEndUL').innerHTML = "";
					for( var dl in doclist ){
					 	var id = doclist[dl].id;
					 	var title = doclist[dl].title;
					 	if(title != undefined){
					 		var n = document.createElement("li");
					        n.innerHTML = "<input type='radio' name='doclistEndId' value='"+id+"' /><label>"+title+"</label>";
					        document.getElementById('doclistEndUL').appendChild(n);
					 	}
					 	
					}
					var n2 = document.createElement("li");
					document.getElementById('doclistEndUL').appendChild(n2);
					var n1 = document.createElement("li");
					
					var url = "/app/my/docin/doclist/createdoclist";
					if(document.getElementById('productId') != null){
						var productId = document.getElementById('productId').value;
						url = "/app/my/docin/doclist/createdoclist?pid="+productId;
					}
					n1.style.fontSize =14+"px";
				    n1.innerHTML = "目前没有适合的豆单,<a target='_blank' onclick='displayNoneAddDoudan();' href='"+url+"'>创建豆单</a>";
				    document.getElementById('doclistEndUL').appendChild(n1);
					document.getElementById('addDoudan').style.display="";
				}
			}
		}
	});
}
function displayNoneAddDoudan(){
	document.getElementById('addDoudan').style.display='none';
}
function addProduct2Doclist(){
	var productId = document.getElementById("doclistProductId").value;
    var doclistEnd = document.getElementsByName("doclistEndId");
    var doclistId ;
    var i = 0;
    for (i=0; i<doclistEnd.length; i++)
    {
        if (doclistEnd.item(i).checked)
        {
            doclistId = doclistEnd.item(i).getAttribute("value");
            break;
        }
    }
    document.getElementById('addDoudan').style.display="none";
	var url = "/my/docin/doclist/adddoclistend.do?random="+Math.round(Math.random()*100)+"&productid="+productId+"&doclistid="+doclistId;
	jQuery.post(url,null,function(data){
		if(data != null){
			if(data == 1){
				document.getElementById('addOk').style.display="";
			}
		}
	});
}
//---------------内容替换------------------//
function divReplace(o,s){
	var d=document,
	o=d.getElementById(o),
	s=d.getElementById(s);
	s.innerHTML=o.innerHTML;
 s.style.display="block";
	o.innerHTML="";
}

//---------------书城终极页增加豆瓣书评按钮切换------------------//
function hasClass(ele,cls) {
  return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}
 
function addClass(ele,cls) {
  if (!this.hasClass(ele,cls)) ele.className += " "+cls;
}
 
function removeClass(ele,cls) {
  if (hasClass(ele,cls)) {
          var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
    ele.className=ele.className.replace(reg,' ');
  }
}
function tagSwitch(selfObj,boxObj,className){
	var lis=document.getElementById(selfObj).getElementsByTagName("li");
	var tmp_tags=document.getElementById(boxObj).getElementsByTagName(className);
	var tags = Array();
	var j = 0;
	for(i=0;i<tmp_tags.length;i++){
		if(tmp_tags[i].className.indexOf("bsComment") > -1){
			tags[j] = tmp_tags[i];
			j++;
		}
	}
	
	for(i=0;i<tags.length;i++){
		tags[i].style.display="none";
		
		if(!!hasClass(lis[i],"comment_cur")){
			tags[i].style.display="block";
		}
		lis[i].onmouseover=function(){
			if(this.className=="comment_cur"){
				return false;
			}
			else{
				thiSwitch(this);
			}
		}
	}
	
	function thiSwitch(obj){         //thiSwitch
		
		for(var i=0;i<lis.length;i++){
			if (lis[i]==obj){
				 addClass(lis[i],"comment_cur");
				 tags[i].style.display="block";
			}
			else{
				 removeClass(lis[i],"comment_cur");
				 tags[i].style.display="none";
			}
		}
	}
}
